package com.lsmo.android.carfans.activity.car;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lsmo.android.carfans.R;
import com.lsmo.android.carfans.model.car.BrandTypeThread;
import com.lsmo.android.carfans.view.car.SelectCarView;
import com.lsmo.android.util.ArrayListAdapter;

public class CarDealerAdapter extends ArrayListAdapter<BrandTypeThread>{
	public static final String TAG = SelectCarView.class.getSimpleName();
	
	public CarDealerAdapter(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View localView1 = convertView;
		ViewHolder localViewHolder;
		LayoutInflater mInflater = ((Activity) mContext).getLayoutInflater();
		
		if(localView1 == null){
			localViewHolder = new ViewHolder();
			localView1 = mInflater.inflate(R.layout.car_adapter_brandtype, null);
			
			localViewHolder.name = (TextView)localView1.findViewById(R.id.car_adapter_brandname);
			localViewHolder.mode = (TextView)localView1.findViewById(R.id.car_adapter_brandmode);
			localViewHolder.adder = (TextView)localView1.findViewById(R.id.car_adapter_brandprice);
			localViewHolder.phone = (TextView)localView1.findViewById(R.id.car_adapter_brandphone);
			localViewHolder.vendorPrice = (TextView)localView1.findViewById(R.id.car_adapter_vendorPrice);
			
			localView1.setTag(localViewHolder);
		} else {
			localViewHolder = (ViewHolder) localView1.getTag();
		}
		
		//销售商名称
		String vendorName = ((BrandTypeThread)mList.get(position)).getJName();
		localViewHolder.name.setText(vendorName);
		
		//联系地址
		String addrString = ((BrandTypeThread)mList.get(position)).getDisAddress();
		localViewHolder.adder.setText(addrString);
		
		//联系电话
		String phoneNoString = ((BrandTypeThread)mList.get(position)).getPhone();
		localViewHolder.phone.setText(phoneNoString);
		
		//店类型
		localViewHolder.mode.setVisibility(View.VISIBLE);
		String modeName = ((BrandTypeThread)mList.get(position)).getDisType();
		StringBuilder localStringBuilder = new StringBuilder("[");
		localStringBuilder.append(modeName);
		localViewHolder.mode.setText(localStringBuilder.toString() +"店"+"]");
		
		return localView1;
	}
	
	class ViewHolder{
	    TextView adder;
	    TextView mode;
	    TextView name;
	    TextView phone;
	    TextView vendorPrice;
    }
	

}
